// Definition

#include "Fighter.h"

Fighter::Fighter()
{
	
}

Fighter::~Fighter()
{
	
}

void Fighter::Load() // The Load function under the fighter class
{
	//const int kWIN_WIDTH = IniFile_GetInt("WinWidth", 800); // 800 is default value, it will be used if cant find win width
	//const int kWIN_HEIGHT = IniFile_GetInt("WinHeight", 600);

	mSprite.Load("fighter.png");

	//mPosition.x = (kWIN_WIDTH / 2); // Set starting position
	//mPosition.y = (kWIN_HEIGHT - 48);
}

void Fighter::Unload()
{
	mSprite.Unload();
}

void Fighter::Update(float deltaTime)
{
	const float kSPEED = 300.0f; // Created once because it is const

	if (Input_IsKeyDown(Keys::RIGHT))
	{
		//position.x += 1.0f; // Dont want frame dependancy movement
		mPosition.x += kSPEED * deltaTime;
	}
	else if (Input_IsKeyDown(Keys::LEFT))
	{
		mPosition.x -= kSPEED * deltaTime;
	}

	if (Input_IsKeyDown(Keys::UP)) // Can do either up or down while moving left or right
	{
		mPosition.y -= kSPEED * deltaTime;
	}
	else if (Input_IsKeyDown(Keys::DOWN))
	{
		mPosition.y += kSPEED * deltaTime;
	}
}

void Fighter::Render()
{
	int width = mSprite.GetWidth();
	int heigth = mSprite.GetHeight();
	SVector2 offset(width * 0.5f, heigth * 0.5f);
	SVector2 renderPos = mPosition - offset;

	mSprite.SetPosition(renderPos);
	mSprite.Render();
}